<?php 
$this->placeholder('display-commercial1')->set(1);
?>
<?php 
$to_add = '';
if ($this->listing->sold == Model_Listing::STATUS_MARK_SOLD) { 
    $to_add = 'sold';
}
?>
<?php $this->placeholder('container-class')->set('ad_detail '.$to_add)?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_ad_detail.v-'.AC_VERSION.'.css'))?>
<script type="text/javascript">var switchTo5x=true;</script>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/sliderkit/jquery.easing.1.3.min.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/sliderkit/lightbox/jquery-lightbox/js/jquery.lightbox-0.5.pack.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/sliderkit/lightbox/jquery-lightbox/js/jquery-ui-1.8.18.custom.min.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/sliderkit/jquery.sliderkit.1.8.min.v-'.AC_VERSION.'.js'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-core.v-'.AC_VERSION.'.css'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-demos.v-'.AC_VERSION.'.css'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/js/sliderkit/lightbox/jquery-lightbox/css/jquery.lightbox-0.5.v-'.AC_VERSION.'.css'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/js/sliderkit/lightbox/jquery-lightbox/css/jquery-ui-1.8.18.custom.v-'.AC_VERSION.'.css'))?>
<!-- Slider Kit compatibility -->

<!--[if IE 6]><link rel="stylesheet" type="text/css" href="<?php echo Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-demos-ie6.v-'.AC_VERSION.'.css')?>" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" type="text/css" href="<?php echo Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-demos-ie7.v-'.AC_VERSION.'.css')?>" /><![endif]-->
<!--[if IE 8]><link rel="stylesheet" type="text/css" href="<?php echo Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-demos-ie8.v-'.AC_VERSION.'.css')?>" /><![endif]-->
<?php $this->headScript()->appendFile('http://api.map.baidu.com/api?v=1.2&services=true')?>
<?php //$this->headScript()->appendFile('http://www.passit.cn/js/passit_bar_big_new.js?pub=0&simple=1')?>
<?php $this->JQuery()->javascriptCaptureStart()?>
    $j(window).load(function(){ //$(window).load() must be used instead of $(document).ready() because of Webkit compatibility
        $j(".photosgallery-captions").sliderkit({
            navscrollatend: true,
            mousewheel:false,
            keyboard:true,
            shownavitems:9,
            auto:false,
            fastchange:true,
            start:0
        });
        var lightboxPath = "js/sliderkit/lightbox/jquery-lightbox/";
        $j("a[rel='group1']").lightBox({
            imageLoading:lightboxPath+"images/lightbox-ico-loading.gif",
            imageBtnPrev:lightboxPath+"images/lightbox-btn-prev.gif",
            imageBtnNext:lightboxPath+"images/lightbox-btn-next.gif",
            imageBtnClose:lightboxPath+"images/lightbox-btn-close.gif",
            imageBlank:lightboxPath+"images/lightbox-blank.gif"
        });
     });
    $j('document').ready(function(){
    	// Control for message
	    $('textarea#message').keydown(function(event) {
	        var charLength = 3000 - $(this).val().length;
	        if (charLength <0) {
	            if ( event.keyCode == 8 || event.keyCode == 46 ) {
	
	            } else {
	                return false;
	            }
	        }
	        else {
	            $('#text_counter').html('剩馀<em>'+charLength + '</em>字元');
	        }
	    });
    	
        ValidateAjax.initialize('send_message_form', '/listing/validate-send-message');
    });
    $j('document').ready(function(){
    	$('#add_comment_submit').live('click',function(){
    		$('#listing_form #error').html('');
    		$('#showfacebox').css('display','none');
    		$.ajax({
    			type: 'post',
				url:  '<?php echo $this->geturl('addnewcomment', 'listing')?>',
				data: $('#listing_form').serialize()+'&id=<?php echo $this->listing_id;?>',
				dataType: 'json',
				success: function(data){
					if(data.status == 'success'){
					var content = data.content;
					var in_html = 		"<section class='like'><ul><li>";
				        in_html +=						"<figure>"; 
				        in_html +=        					"<a href='"+data.url+"'>";
				        in_html +=            					"<img src='"+data.pic+"' alt='anonymous'>";
				        in_html +=           				"</a>";  
				        in_html +=        				"</figure>";
		                in_html +=						"<h2><a class='comment_user_name'>"+data.user_name+"</a></h2>";
		            	in_html +=					"</li>";
		            	in_html +=					"<li style='padding-left: 6px; width: 75%;' class='comment_content'><span id='showcomment_username'><a href='"+data.url+"'>"+data.user_name+"</a></span><br />"+content+"<span style='padding-left:10px;color:gray;'>"+data.created_at+"</span></li>";
		            	in_html +=					"<li style='padding-left:25px;color:#999999;' class='inform_comment'>举报</li>";
			            in_html +=					"</ul>";
        				in_html +=		"</section>";
						$('.add_comment_show_place').append(in_html);
						$('#add_comments').val('');
					}else {
						$.each(data.status.add_comments,function(key,val){
							$('#listing_form #error').append(val+'<br />');
						})
						$('#listing_form #error').html();
					}
				}
    		})
    		
    	})
    });
    
    $j('document').ready(function() {
		$( "#dialog" ).dialog({
			autoOpen: false,
			width: 600,
			title: "举报不良信息",
			modal: true,
			//show: "blind",
			//hide: "explode"
		});
		
		$("#dialog_success").dialog({
			autoOpen: false,
			width: 300,
			height: 100,
			title: "举报成功",
			modal: true,
		})
		
		$( ".inform_comment" ).live('click', function() {
			var username = $(this).parent().find('.comment_user_name').text();
			var comment_id = $(this).parent().find('.comment_user_name').attr('id');
			var content = $(this).parent().find('.comment_content span').eq(1).text();
			var createtime = $(this).parent().find('.comment_content span').eq(2).text();
			$('#dialog').find('.fwpa_tool .fwpa_a').text(username).attr('id',comment_id);
			$('#dialog').find('.fwpa_s a').html($(this).parent().find('li').eq(0).find('figure a').html());
			$('#dialog').find('.fw_pub_area .fwpa_c span').eq(0).html(username);
			$('#dialog').find('.fw_pub_area .fwpa_c span').eq(1).html(content);
			$('#dialog').find('.fw_pub_area .fwpa_c span').eq(2).html(createtime);
			$( "#dialog" ).dialog( "open" );
			return false;
		});
		
		$("#add_complain_submit").live('click', function(){
			$('#complain_form #error').html('');
			var content = $('.fwpa_shu').val();
			//alert(content);
			$.ajax({
				type: 'post',
				url:  '<?php echo $this->geturl('addnewcomplain', 'listing')?>',
				data: $('#complain_form').serialize()+'&id='+$('#dialog').find('.fwpa_tool .fwpa_a').attr('id'),
				dataType: 'json',
				success: function(data){
					if(data.status == 'success'){
						$('#complain_form input').val('');
						$( "#dialog" ).dialog( "close" );
						$( "#dialog_success" ).dialog("open");
						setTimeout("$( '#dialog_success' ).dialog('close');", 1500);
					}else{
						$.each(data.status.addcomplain.n,function(key,val){
							$('#complain_form #error').append(val+'<br />');
						})
						$('#complain_form #error').html();
					}
				},
			})
		})
		
		$("#closefacebox").live('click', function(){
			$('#showfacebox').css('display','none');
		})
		
	});
	
	$j('document').ready(function(){
		var t;
		var s;
		
		$('#facebutton').click(function(){
    		if($('#showfacebox').css('display') != 'block')
    		{
    			$('#showfacebox').css('display','block');
    			s=setTimeout("test()", 3000);
    		}else{
    			clearTimeout(t);
				clearTimeout(s);
    			$('#showfacebox').css('display','none');
    		}
    	})
    	
    	$('#showfacebox ul li').click(function(){
    		var arr = new Array();
    		<?php foreach ($this->allsign as $ket=>$sign):?>
    			arr["<?php echo $ket;?>"] = "<?php echo $sign;?>";
    		<?php endforeach;?>
    		var face = arr[$(this).attr('id').split('_')[1]];
    		face = face.toString();
    		face = face.substr(1,(face.length-2));
    		$('#listing_form textarea').val($('textarea').val()+face);
    	})
    	
		$("#showfacebox").mouseout(function(){
			t=setTimeout("test()", 3000);
			return false;
		})
		$("#showfacebox").mouseover(function(){
			clearTimeout(t);
			clearTimeout(s);
			if($(this).css('display') != 'block'){
				$(this).css('display','block');
			}
		})
	})
	function test(){
		$('#showfacebox').css('display','none');
		return false;
	}
<?php $this->JQuery()->javascriptCaptureEnd()?>
<?php $this->headStyle()->captureStart()?>
.inform_comment, #facebutton{
	cursor:pointer;
}
.ui-dialog-titlebar{
	background: #1D77C7;
}
.ui-widget-overlay{
	background-image:url();
}
#showfacebox{
	display:none;
}
#showfacebox ul li{
	cursor: pointer;
	height: 25px;
	float: left;
	padding-left: 15px;
	padding-top: 5px;
}

.fwpa_s a{
	cursor:pointer;
}
#dialog .lb_border {
    border-bottom-color: #F2F2F2;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    margin-bottom: 0;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 0;
    padding-bottom: 5px;
    padding-left: 5px;
    padding-right: 5px;
    padding-top: 10px;
    width: 555px;
}
#dialog .fw_root {
    color: #666666;
    line-height: 160%;
}
#dialog .fw_pub_area {
    border-bottom-color: #F2F2F2;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    margin-bottom: 0;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 0;
    padding-bottom: 5px;
    padding-left: 5px;
    padding-right: 5px;
    padding-top: 10px;
    width: 555px;
}
#dialog .fwpa_tool {
    height: 30px;
    line-height: 30px;
}
#dialog .fwpa_s {
    -moz-border-bottom-colors: none;
    -moz-border-image: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    background-attachment: scroll;
    background-clip: border-box;
    background-color: #FFFFE5;
    background-image: none;
    background-origin: padding-box;
    background-position: 0 0;
    background-repeat: repeat;
    background-size: auto auto;
    border-bottom-color: #CCCCCC;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    border-left-color-ltr-source: physical;
    border-left-color-rtl-source: physical;
    border-left-color-value: #CCCCCC;
    border-left-style-ltr-source: physical;
    border-left-style-rtl-source: physical;
    border-left-style-value: solid;
    border-left-width-ltr-source: physical;
    border-left-width-rtl-source: physical;
    border-left-width-value: 1px;
    border-right-color-ltr-source: physical;
    border-right-color-rtl-source: physical;
    border-right-color-value: #CCCCCC;
    border-right-style-ltr-source: physical;
    border-right-style-rtl-source: physical;
    border-right-style-value: solid;
    border-right-width-ltr-source: physical;
    border-right-width-rtl-source: physical;
    border-right-width-value: 1px;
    border-top-color: #CCCCCC;
    border-top-style: solid;
    border-top-width: 1px;
    overflow-x: hidden;
    overflow-y: hidden;
    padding-bottom: 10px;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 10px;
    width: 530px;
}
#dialog .fwpa_s a {
    float: left;
    height: 50px;
    width: 50px;
}
#dialog .fwpa_c {
    float: right;
    overflow-x: hidden;
    overflow-y: hidden;
    padding-bottom: 15px;
    width: 470px;
}
#dialog .fwpa_p {
    padding-bottom: 15px;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 15px;
    text-align: center;
}
#dialog .fwpa_ww {
    height: 30px;
    line-height: 30px;
    padding-bottom: 20px;
    padding-left: 0;
    padding-right: 0;
    padding-top: 5px;
}
#dialog .fwpa_ww span {
    color: #999999;
    line-height: 12px;
    margin-bottom: auto;
    margin-left: 5px;
    margin-right: 5px;
    margin-top: auto;
}
#dialog .fwpa_shu {
    -moz-border-bottom-colors: none;
    -moz-border-image: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    border-bottom-color: #AAAAAA;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    border-left-color-ltr-source: physical;
    border-left-color-rtl-source: physical;
    border-left-color-value: #AAAAAA;
    border-left-style-ltr-source: physical;
    border-left-style-rtl-source: physical;
    border-left-style-value: solid;
    border-left-width-ltr-source: physical;
    border-left-width-rtl-source: physical;
    border-left-width-value: 1px;
    border-right-color-ltr-source: physical;
    border-right-color-rtl-source: physical;
    border-right-color-value: #AAAAAA;
    border-right-style-ltr-source: physical;
    border-right-style-rtl-source: physical;
    border-right-style-value: solid;
    border-right-width-ltr-source: physical;
    border-right-width-rtl-source: physical;
    border-right-width-value: 1px;
    border-top-color: #AAAAAA;
    border-top-style: solid;
    border-top-width: 1px;
    height: 28px;
    line-height: 23px;
    overflow-x: hidden;
    overflow-y: hidden;
    padding-bottom: 1px;
    padding-left: 5px;
    padding-right: 5px;
    padding-top: 1px;
    vertical-align: middle;
    width: 225px;
}
#dialog .sub_div {
    margin-bottom: 15px;
    overflow-x: hidden;
    overflow-y: hidden;
    padding-bottom: 0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 15px;
}
#dialog .sub_div .fw_cancel {
    color: #999999;
    height: 30px;
    line-height: 30px;
}
#showcomment_username{
	color:#FF89A7;
}
#dialog_success{
	line-height: 3;
}
<?php $this->headStyle()->captureEnd()?>
<?php 
    $cache_key = 'listing_display_'.$this->listing->_id.'_'.$this->current_language.'_'.(empty($_GET['lng']) ? '' : $_GET['lng']);
//    $test = !Zend_Registry::isRegistered('loggedin_user');
?>
<?php if (!$output = $this->cacheOutput()->start($cache_key)):?>
<section class="breadcrumb">
    <?php if (!empty($this->search)):?>
        <dl class="back">
            <dd><a href="<?php echo $this->search->url?>">&lt; 返回</a></dd>
        </dl>
    <?php endif;?>
    <?php if (!empty($this->listing->category)):?>
        <dl class="path">
            <dt>列于分类：</dt>
            <dd>
                <?php foreach($this->listing->category as $category):?>
                    <?php $tree = $category->getParentTree(); $to_add = '';?>
                    <?php foreach($tree as $cat):?>
                        <?php echo $to_add;?><a href="<?php echo $cat->url()?>"><?php echo $cat->name?></a>
                        <?php $to_add = '&raquo;';?>
                    <?php endforeach; $cat_search = (string)$cat->path[0];?>
                    
                <?php endforeach;?>
            </dd>
      </dl>
    <?php endif;?>
</section>
<article class="article box">
    <section class="main_section">
    <?php if(!empty($this->listing->remark)):?>
            <section class="remark box">
                <p><span>卖家<em><?php echo $this->listing->user->username?></em>说：</span>“<?php echo mb_substr($this->listing->remark, 0, 60)?>”<span class="arrow"></p></span>
            </section>  
        <?php endif;?>
        <h1><em><?php echo $this->listing->title?></em></h1>
        <dl class="intro">
			<span>
				<?php
				if($this->listing->_type[0] == "Model_Listing_Job"){
					$views1 = Model_Listing_Job::getSalaryPostAd();
					$views2 = Model_Listing_Job::getSalaryHourPostAd();
					echo '<dd class="price">';
					if(!empty($this->listing->salary) && !empty($this->listing->salary_hour)){
						echo "<span>".$views1[$this->listing->salary]."</span><em>(月薪)</em>/<span>".$views2[$this->listing->salary_hour]."</span><em>(时薪)</em>";
					}else{
						if(!empty($this->listing->salary)){
							echo "<span>".$views1[$this->listing->salary]."</span><em>(月薪)</em>";
						}elseif(!empty($this->listing->salary_hour)){
							echo "<span>".$views2[$this->listing->salary_hour]."</span><em>(时薪)</em>";
						}
					}
					echo '</dd>';
				}else{
					echo $this->price($this->listing);
				}
				?>
			</span>
			<span class="location">
				<?php
				if($this->listing->_type[0] == "Model_Listing_Job"){
					if(!empty($this->listing->company)){
						echo $this->listing->company->name;
					}
				}elseif($this->listing->_type[0] == "Model_Listing_Commercial" || $this->listing->_type[0] == "Model_Listing_Residential"){
					if(!empty($this->listing->street)){
						echo $this->listing->street;
					}
				}
				?>
			</span>
		</dl>
        <section class="func">
        <?php 
            //user specific items
            $is_like = Model_Like::isLiked($this->listing->_id);
            $bookmark = !empty($this->bookmark) ? $this->bookmark : array();
        ?>

            <a href="#" rel="<?php echo $this->geturl(($is_like ? 'unlike' : 'like'),'follow', array('id' => (string)$this->listing->_id))?>" class="like to_like <?php echo ($is_like ? 'selected' : '')?>"><span>喜欢<em><?php echo Model_Like::getCount($this->listing->_id)?></em></span></a>
            <a href="#" class="save to_bookmark <?php echo (in_array($this->listing->_id, $bookmark) ? 'selected' : '') ?>" rel="<?php echo (string)$this->listing->_id?>"><span>收藏</span></a>
            <?php if (empty($this->listing->user->nsme)):?>
                <a href="#msgform" class="msg"><span>发讯息</span></a>
            <?php else:?>
                <a class="ext" target="_blank" href="<?php echo $this->listing->url?>">购买链接</a>
            <?php endif;?>
                <!--Passit BUTTON BEGIN-->
                     <div class="passit_barDiv"><a class="passit_default" href="http://www.passit.cn/bookmark.html" target="_blank"></a></div>           
                        <script type="text/javascript">
                        var passit_title = "我正在貓找網分享了1998 Porsche 996 Carrera 2 (Code 0310), 快來看看哦！";//自定义分享标题，删除和留空表示使用默认
                        var passit_url = "http://www.aaa.com/";//自定义分享网址，删除和留空表示使用默认
                        var passit_content= "";//自定义分享内容，删除和留空表示使用默认Meta中的描述
                        var passit_image= "";//自定义分享图片，删除和留空表示不分享图片
                        var sina_appkey= "";//sina微博appkey,删除和留空表示使用默认
                        var qq_appkey= "";//腾讯微博appkey,删除和留空表示使用默认
                        </script>
                        <script type="text/javascript">
                            bookmark_service_div="qq,kxzt,qqxy,baiduHi,bookmark,baidu,douban,sohuweibo,163weibo,more";
                            bookmark_service="share,qqkj,sinaweibo,xnzt,qqweibo,more";
                        </script>   
                        <!--Passit BUTTON END-->
         
                   </section>
        <?php if ($this->listing->sold == Model_Listing::STATUS_MARK_SOLD):?>
            <section class="sold">
                <h3>此物品已售或過期。<span>我們還有類似的物品，看看以下</span></h3>
                <section class="user_ad gallery hor">
                    <h4>此賣家的物品 <span>(<a href="#">更多</a>)</span></h4>
                    <ul>
                        <?php if ($this->similar_ads_other_sold):?>
                            <?php foreach($this->similar_ads_other_sold as $item):?>
                                <li>
                                    <?php
                                        $this->partial()->setObjectKey('model');
                                        echo $this->partial(
                                            'index/listing-element.phtml',
                                            'search',
                                            array(
                                                'item'                  => $item,
                                                'photo_width'           => 144,
                                                'photo_height'          => 144,
                                                'photo_params'          => array(),
                                                'display_photo_if_not_exists' => true,
                                                'display_date'                => false,
                                                'display_category'            => false,
                                                'display_customization'       => false,                                 
                                        ));
                                    ?>
                                </li>
                            <?php endforeach;?>
                        <?php endif;?>
                    </ul>
                </section>
                <section class="other_user_ad gallery hor">
                    <h4>此賣家的物品 <span>(<a href="#">更多</a>)</span></h4>
                    <ul>
                        <?php if ($this->similar_ads_user):?>
                            <?php foreach($this->similar_ads_user as $item):?>
                                <li>
                                    <?php
                                        $this->partial()->setObjectKey('model');
                                        echo $this->partial(
                                            'index/listing-element.phtml',
                                            'search',
                                            array(
                                                'item'                  => $item,
                                                'photo_width'           => 144,
                                                'photo_height'          => 144,
                                                'photo_params'          => array(),
                                                'display_photo_if_not_exists' => true,
                                                'display_date'                => false,
                                                'display_category'            => false,
                                                'display_customization'       => false,                                        
                                        ));
                                    ?>

                               </li>
                            <?php endforeach;?>
                        <?php endif;?>
                    </ul>
                </section>      
            </section>
        <?php endif;?>
    <?php if(!empty($this->listing->photos)):?>
        <section class="photo">
            <h3>共<span><?php echo count($this->listing->photos);?></span>张相片</h3>
            <!-- Start Advanced Gallery Html Containers -->
            <div class="sliderkit photosgallery-captions">
                <div class="sliderkit-nav">
                    <div class="sliderkit-nav-clip">
                        <ul>
                            <?php foreach($this->listing->photos as $k => $photo) :?>
                                <li> 
                                    <a href="<?php echo $this->thumbnail()->scale($photo)?>" title=""> <img src="<?php echo $this->thumbnail()->scale($photo, 51, 51);?>" alt=""></a>
                                </li>
                            <?php endforeach;?>
                        </ul>
                    </div>
                </div>
                <div class="sliderkit-panels">
                    <?php foreach($this->listing->photos as $k => $photo) :?>
                        <div class="sliderkit-panel">
                            <a href="<?php echo $this->thumbnail()->scale($photo)?>" title="[title]" rel="group1">
                                <img src="<?php echo $this->thumbnail()->scale($photo, 568, 424);?>" alt="[Alternative text]" />
                            </a> 
                        </div>
                    <?php endforeach;?>
                </div>
            </div>
        </section>
    <?php endif;?>
    <section class="info add_comment_show_place">
        <h3>详细资料</h3>
        <section class="more">
            <?php if(!empty($this->listing->address)):?>
                <section class="map">
                    <h3>地图资讯</h3>
                    <dl>
                        <dd><img src="images/baiduMap.jpg"></dd>
                    </dl>
                </section>
            <?php endif;?>
            <?php if(!empty($this->listing->contact_name) || !empty($this->listing->contact_tel) || !empty($this->listing->contact_msn)):?>
                <section class="contact">
                    <h3>联络资料</h3>
                    <?php
                        $contact_name = $this->listing->contact_name;
                        $contact_phone = $this->listing->contact_tel;
                        $contact_msn = $this->listing->contact_msn;
                        if (!empty($this->listing->company)) {
                            if (empty($contact_name) || empty($contact_phone)) {
                                $contact_name  = $this->listing->company->contact_name;
                                $contact_phone = $this->listing->company->contact_phone;
                                $contact_msn   = $this->listing->company->contact_messenger;
                            }
                        }
                    ?>

                    <?php if(!empty($this->listing->company)):?>
                        <dl>
                            <dt>公司名称</dt>
                            <dd>
                                <a href="<?php echo $this->listing->company->url()?>">
                                    <?php echo $this->listing->company->company_name;?>
                                </a>
                            </dd>
                        </dl>
                    <?php endif;?>

                        <dl>
                            <dt>联系人</dt>
                            <dd><?php echo $contact_name;?></dd>
                        </dl>
                        <dl>
                            <dt>联系电话</dt>
                            <dd><?php echo $contact_phone;?></dd>
                        </dl>
                        <dl>
                            <dt>MSN/QQ</dt>
                            <dd><?php echo $contact_msn;?></dd>
                        </dl>

                </section>
            <?php endif;?>
        </section>
        <section class="general">
                <?php if(!empty($this->listing->company)):?>
                    <dl>
                        <dt>刊登者</dt>
                        <dd><a href="<?php echo $this->listing->company->url()?>"><?php echo $this->listing->company->name;?></a></dd>
                    </dl>
                <?php endif;?>
                <?php if($this->listing->_type[0] != "Model_Listing_Job"):?>
                    <dl>
                        <dt>价格</dt>
                        <dd><?php echo $this->price($this->listing, false);?></dd>
                    </dl>
                <?php endif;?>
                <?php if(!empty($this->listing->brandsale) && $this->listing->brandsale == 1):?>
                    <dl>
                        <dt>&nbsp;</dt>
                        <dd>带牌销售</dd>
                    </dl>
                <?php endif;?>
                <?php if($this->listing->_type[0] != "Model_Listing_Job" && !empty($this->listing->street)):?>
                    <dl>
                        <dt>地址</dt>
                        <dd><?php echo $this->listing->street?></dd>
                    </dl>
                <?php endif;?>
                <dl><dt>地点</dt>
                <dd>
                    	<a href="<?php echo $this->geturl('regular','search', null, null, array('small_category_list' => $cat_search, 'city' => $this->listing->area_l2->area_l1->city))?>"><?php echo $this->listing->area_l2->area_l1->city_name?></a>,                 	 
                    <?php if(!empty($this->listing->area_l2)):?>
                        <?php if((string)$this->listing->area_l2->_id != ENTIRE_CITY):?>
                	        <a href="<?php echo Ac_Util::getCrossLink($this->listing->area_l2->area_l1->_id, 'area_l1', $this->listing, $this->geturl('regular','search'))?>"><?php echo $this->listing->area_l1?></a>,
                        <?php endif;?>
                    	<a href="<?php echo Ac_Util::getCrossLink($this->listing->area_l2->_id, 'area_l2', $this->listing, $this->geturl('regular','search'))?>"><?php echo $this->listing->area_l2?></a>
                    <?php endif;?>
				</dd></dl>
                <dl><dt><?php echo $this->t('发布日期')?></dt>
                <dd><?php echo date(MEDIUM_DATE_FORMAT, $this->listing->posted_at)?></dd></dl>
                <?php if(!empty($this->listing->tag) && is_array($this->listing->tag)):?>
				<dl><dt><?php echo $this->t('标签')?></dt>
                <dd><?php foreach($this->listing->tag as $tag):?><?php if(empty($tag)){continue;}?><a href="<?php echo $this->geturl('regular','search', null, null, array('small_category_list' => $cat_search, 'keyword' => trim($tag)))?>"><?php echo trim($tag);?></a>, <?php endforeach;?></dd></dl>
                <?php endif;?>
        </section>
        <?php $partial_name = $this->listing->getAdDetailPartialName();?>
        <?php if(!empty($partial_name)):?>
            <?php echo $this->Partial('index/'.$partial_name);?>
        <?php endif;?>
        <section class="desc">
            <h3>描述</h3>
            <dl>
                <dd>
                    <?php   $text = $this->listing->description;
                            if (preg_match_all('#<a[^<]*(http://\S*)\s#u', $text.' ', $matches)) {
                                foreach ($matches[1] as $match) {
                                     $text = str_replace($match, '<a rel="nofollow" target="_blank" href="'.Model_Link::getTrackingLink(trim($match)).'">'.$match.'</a>', $text);
                                }
                            }

                            if (preg_match_all('#([^\/]www\S*)\s#u', $text.' ', $matches)) {
                                foreach ($matches[1] as $match) {
                                     $text = str_replace($match, '<a rel="nofollow" target="_blank" href="'.Model_Link::getTrackingLink('http://'.trim($match)).'">'.$match.'</a>', $text);
                                }
                            }
                            if (empty($text)) {
                               // echo $this->t('No description provided');
                            } else {
                                echo nl2br($text);
                            }
                    ?>
                </dd>
            </dl>
        </section>
        <section class="desc">
        <h3 class="required" for="add_comments">添加评论</h3>
        <dl>
        	<form method="post" action="" enctype="application/x-www-form-urlencoded" id="listing_form">
                <dd>
                	<textarea rows="12" cols="65" id="add_comments" name="add_comments"></textarea>
                </dd>
                <dd>
                	<img src='images/add_face.png' alt='test' style='margin-left: 20px;' id='facebutton'>
                	<span id='error' style='color:#f00;'></span>
                </dd>
                <dd>
               		<div class="button em">
               			<?php if(empty($this->loggedin_user->_id)):?>
						<p class='button'><a href='<?php  echo $this->geturl('login','user');?>'>登录</a></p>
						<?php else:?>
						<button type="button" id="add_comment_submit" name="register" style="margin-right:10px;">添加评论</button>
						<?php endif;?>
               		</div>
                </dd>
                <dd style='padding-bottom:10px;'>
                <div style='position: relative; max-width:400px; height:250px; border:1px solid pink; z-index:100; background:white;' id='showfacebox'>
                	<div style='height:20px;width:100%'>
                		<div style='float:right;color:red;margin-right:20px; cursor:pointer;' id='closefacebox'>x</div>
                	</div>
					<ul>
					<?php foreach ($this->allface as $key=>$face):?>
					<li id='face_<?php echo $key;?>'><?php echo $face;?></li>
					<?php endforeach;?>
					</ul>
				</div>
				</dd>
			</form>
        </dl>
        </section>
        <?php foreach ($this->history_comments as $history_comment):?>
        	<section class='like'>
        		<ul>
        			<li>
		        		<figure> 
		                	<a href="<?php echo Model_User::find(new MongoId($history_comment->user_id))->url();?>">
		                    	<img src="<?php echo $this->thumbnail()->scale(Model_User::find(new MongoId($history_comment->user_id))->profile_picture, 54, 54, true, true);?>" alt="anonymous">
		                    </a>  
		                </figure>
                		<h2 class='comment_user_name' id='c_<?php echo $history_comment->_id;?>'><a href="#"><?php echo Model_User::find(new MongoId($history_comment->user_id))->username;?></a></h2>
            		</li>
            		<li style='padding-left: 6px; width: 75%;' class='comment_content'>
            			<span id='showcomment_username'>
            				<a href="<?php echo Model_User::find(new MongoId($history_comment->user_id))->url();?>">
            					<?php echo Model_User::find(new MongoId($history_comment->user_id))->username;?>
            				</a>
            			</span><br />
            			<span>
            			<?php 
            				if(Model_Util::againstBannedWords($history_comment->content) === true || $history_comment->status == "reactivated" )
            				{
            					echo Model_Comment::addface($history_comment->content);
            				}
            				else{
            					echo "Your comment will be reviewed by our moderators. Thank you.";
            				}
            			?>
            			</span>
            			<span style='padding-left:10px;color:gray;'>
            				<?php echo date ('Y-m-d H:i', $history_comment->created_at->sec);?>
            			</span>
            		</li>
            		<li style='padding-left:25px;color:#999999;' class='inform_comment'>举报</li>
            	</ul>
        	</section>	
        <?php endforeach;?>
        <div id="dialog" title="Basic dialog">
        	<div class="lb_bd r5">
        		<div class="lb_border">
        			<p class="fw_root"><img src="/img/message-icon.png">不良信息是指含有各类卖家店铺、商品广告、虚假中奖信息或其他骚扰你正常浏览的内容</p>
        		</div>
        		<div class="fw_pub_area">
	        		<div class="fwpa_tool">你要举报的是<a class="fwpa_a"></a>的评论：</div>
	        		<div class="fwpa_s">
	        			<a></a>
	        			<div class="fwpa_c">
	        				<span style='color:#4FA6D7;'></span><br />
	        				<span></span>
	        				<span style='padding-left:10px;color:gray;'></span>
	        			</div>
	        		</div>
	        		<form id='complain_form' action='' method='post' enctype="application/x-www-form-urlencoded"> 
	        			<div class="fwpa_ww" style='padding-top:25px; padding-buttom:0px;'>举报原因：<input type="text" name="n" class="fwpa_shu r3"></div>
	        			<span style="color:#f00;" id="error"></span>
	        		</form>
        		</div>
        		<div class="sub_div">
        			<div class="button em" style='text-align:left;padding-top:0px;'>
						<button style="margin-right:10px;" name="register" id="add_complain_submit" type="button">举报</button>
						<span class="fw_cancel">请放心,我们会尽快处理，你的隐私将会得到保护</span>
					</div>
        		</div>
        	</div>
        </div>
        <div id="dialog_success">
        	<p style='padding-left: 5px;'>您的举报已经提交，我们会尽快处理</p>
        </div>
    </section>
    <!--section class="ad">
      <a href="#"><img src="images/ad_728_90.jpg"></a>      
    </section-->  
    <?php if (Model_Like::getCount($this->listing->_id) > 0) :?>
        <section class="like">
            <h3><span><?php echo Model_Like::getCount($this->listing->_id)?></span>个人喜欢这个讯息</h3>
            <ul>
                <?php foreach($this->listing->likes() as $item):?>
                    <li>
                        <?php if(!empty($item->user)):?>
                            <figure>
                               <a href="<?php echo $item->user->url;?>">
                                   <img src="<?php echo $this->thumbnail()->scale($item->user->photo, 54, 54, true, true);?>" alt="<?php echo $item->user->name?>">
                               </a>
                            </figure>
                            <h2><a href="<?php echo $item->user->url?>"><?php echo $item->user->name?></a></h2>
                        <?php else:?>
                            <figure>
                               <a href="#">
                                   <img src="<?php echo $this->thumbnail()->scale('', 54, 54, true, true);?>" alt="anonymous">
                               </a>
                            </figure>
                            <h2><a href="#">隐者猫</a></h2>
                        <?php endif;?>
                    </li>
                <?php endforeach;?>
            </ul>
        </section>
        
    <?php endif;?>
    <?php if (empty($this->listing->user->nsme)):?>
        <a name="msgform"></a>
        <section class="send_msg">
            <h3>发私人讯息</h3>
            <?php if(!empty($this->send_message_form)):?>
                <?php echo $this->send_message_form->setAttrib('id', 'send_message_form');?>
            <?php endif;?>
        </section>
    <?php endif;?>
    </section>
    <aside class="aside">
        <section class="user info personal">
            <?php if(!empty($this->listing->user->cid)):?>
                <figure>
                    <a href="<?php echo $this->listing->user->company->url()?>">
                        <img src="<?php echo $this->thumbnail()->scale($this->listing->user->company->image, 80, 80, true, true);?>" alt="<?php echo $this->listing->company->company_name?>">
                    </a>
                </figure>          
                <h3><a href="<?php echo $this->listing->user->company->url()?>"><?php echo $this->listing->user->company->company_name?></a></h3>
            <?php else:?>
                <figure>
                    <a href="<?php echo $this->listing->user->url()?>">
                        <img src="<?php echo $this->thumbnail()->scale($this->listing->user->pp, 80, 80, true, true);?>" alt="<?php echo $this->listing->user->name?>">
                    </a>
                </figure>          
                <h3><a href="<?php echo $this->listing->user->url()?>"><?php echo $this->listing->user->name?></a></h3>

            <?php endif;?>
            <?php if(!empty($this->listing->user->phone_number)):?>
                <p class="tel">联系电话<a href="#"><?php echo $this->listing->user->phone_number?></a></p>
            <?php endif;?>
            <p class="func">
                <?php 
                    $is_follow = Model_Follow::isFollowing($this->listing->user->_id);
                    if(!empty($this->listing->user->cid)):?>
                        <a href="#" rel="<?php echo $this->geturl(($is_follow ? 'unfollow' : 'follow'),'follow', array('id' => (string)$this->listing->user->_id))?>" class="follow to_follow <?php echo ($is_follow ? 'selected' : '')?>"><span>关注<em><?php echo Model_Follow::getCountFollowers($this->listing->user->_id)?></em></span></a>
                    <?php else:?>
                        <a href="#" rel="<?php echo $this->geturl(($is_follow ? 'unfollow' : 'follow'),'follow', array('id' => (string)$this->listing->user->_id))?>" class="follow to_follow <?php echo ($is_follow ? 'selected' : '')?>"><span>关注<em><?php echo Model_Follow::getCountFollowers($this->listing->user->_id)?></em></span></a>
                    <?php endif;?>
                <?php if (empty($this->listing->user->nsme)):?>
                    <a href="#msgform" class="msg"><span>发讯息</span></a>
                <?php else:?>
                    <a class="ext" target="_blank" href="<?php echo $this->listing->url?>">购买链接</a>
                <?php endif;?>
            </p>
            <ul>
                <?php if (!empty($this->listing->user->cid)):?>
                    <li><a href="#"><span>关注</span><?php echo (int)$this->listing->user->company->count_following;?></a></li>
                    <li><a href="#"><span>粉丝</span><?php echo (int)$this->listing->user->company->count_followers;?></a></li>
                    <li><a href="#"><span>被喜欢</span><?php echo (int)$this->listing->user->company->count_likes?></a></li>
                <?php else:?>
                    <li><a href="#"><span>关注</span><?php echo (int)$this->listing->user->count_following;?></a></li>
                    <li><a href="#"><span>粉丝</span><?php echo (int)$this->listing->user->count_followers;?></a></li>
                    <li><a href="#"><span>被喜欢</span><?php echo (int)$this->listing->user->count_likes?></a></li>
                <?php endif;?>
            </ul>
        </section>
        <!--section class="ad medium"> <a href="#"><img src="images/ad_300_250.jpg"></a> </section-->
        <?php $list = $this->listing->user->followers();?>
        <?php if ($list->count() > 0):?>
            <section class="user friend">
                <h3>他的粉丝</h3>
                <ul>
                    <?php foreach($list as $item):?>
                        <?php $item = $item->user_followed?>
                        <li>
                            <?php if(!empty($item->user)):?>
                                <figure>
                                   <a href="<?php echo $item->user->url;?>">
                                       <img src="<?php echo $this->thumbnail()->scale($item->user->photo, 54, 54, true, true);?>" alt="<?php echo $item->user->name?>">
                                   </a>
                                </figure>
                                <h2><a href="<?php echo $item->user->url?>"><?php echo $item->user->name?></a></h2>
                            <?php else:?>
                                <figure>
                                   <a href="#">
                                       <img src="<?php echo $this->thumbnail()->scale('', 54, 54, true, true);?>" alt="anonymous">
                                   </a>
                                </figure>
                                <h2><a href="#">隐者猫</a></h2>
                            <?php endif;?>
                        </li>
                    <?php endforeach;?>
                </ul>
            </section>
        <?php endif;?>
        <?php if ($this->similar_ads_user):?>
            <section class="user post gallery hor">
                <h3>他的近似讯息</h3>
                <ul>
                    <?php foreach($this->similar_ads_user as $item):?>
                        <li>
                            <?php
                                $this->partial()->setObjectKey('model');
                                echo $this->partial(
                                    'index/listing-element.phtml',
                                    'search',
                                    array(
                                        'item'                  => $item,
                                        'photo_width'           => 144,
                                        'photo_height'          => 144,
                                        'photo_params'          => array(),
                                        'display_photo_if_not_exists' => true,
                                        'display_date'                => false,
                                        'display_category'            => false,
                                        'display_customization'       => false,                                        
                                ));
                            ?>

                       </li>
                    <?php endforeach;?>
                </ul>
            </section>
        <?php endif;?>

        <?php if ($this->similar_ads_other):?>
            <section class="other post gallery hor">
                <h3>其他人的近似讯息</h3>
                <ul>
                    <?php foreach($this->similar_ads_other as $item):?>
                        <li>
                            <?php
                                $this->partial()->setObjectKey('model');
                                echo $this->partial(
                                    'index/listing-element.phtml',
                                    'search',
                                    array(
                                        'item'                  => $item,
                                        'photo_width'           => 144,
                                        'photo_height'          => 144,
                                        'photo_params'          => array(),
                                        'display_photo_if_not_exists' => true,
                                        'display_date'                => false,
                                        'display_category'            => false,
                                        'display_customization'       => false, 
                                ));
                            ?>
                        </li>
                    <?php endforeach;?>
                </ul>
            </section>
        <?php endif;?>

        <!--section class="ad medium"> 
            <a href="#"><img src="images/ad_300_250.jpg"></a> 
        </section-->
    </aside>
</article>
            <?php $this->cacheOutput()->end(array('listing', $cache_key), 3600)?>
            <!-- not cached: <?php echo $cache_key?> -->
        <?php else :?>
            <?php echo $output?>
            <!-- cached: <?php echo $cache_key?> -->
        <?php endif;?>

<?php if($this->list_latest_cat):?>
    <section class="gallery hor box">
        <h3>华强北甄子丹喜欢的分享...</h3>
        <ul>
            <?php foreach($this->list_latest_cat->limit(8) as $item):?>
            <li>
                <?php
                    $this->partial()->setObjectKey('model');
                    echo $this->partial(
                        'index/listing-element.phtml',
                        'search',
                        array(
                            'item'                  => $item,
                            'photo_width'           => 144,
                            'photo_height'          => 144,
                            'photo_params'          => array(),
                            'display_photo_if_not_exists' => true,
                            'display_date'                => false,
                            'display_category'            => false,
                            'display_customization'       => false,                                        
                    ));
                ?>
            </li>
            <?php endforeach;?>
        </ul>
    </section>
<?php endif;?>
<?php 
/*$xx = Model_Listing_Attribute::one(array('_id' => new MongoId('4cda65638835c11410060900')));
$xx->nm_sc = '三菱';
$xx->save();*/
?>
